const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const router = require('./router');
const app = express();

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
app.use('/static', express.static(__dirname + '/static'));
app.use('/', router);

const server = app.listen(5001, () => {
  const { address, port } = server.address()
  console.log('server is running on http://%s:%s', address, port)
});

// const fs = require('fs');
// const https = require('https');

// const privateKey = fs.readFileSync('https/2_api.xizhouhezai.com.key', 'utf8')
// const certificate = fs.readFileSync('https/1_api.xizhouhezai.com_bundle.crt', 'utf8')
// const credentials = { key: privateKey, cert: certificate }
// const httpsServer = https.createServer(credentials, app)
// const SSLPORT = 18082

// httpsServer.listen(SSLPORT, function() {
//   console.log('HTTPS Server is running on: https://localhost:%s', SSLPORT)
// })

